package com.example.chain.auth;

public abstract class Handler {
    protected Handler next;

    public void next(Handler next) {
        this.next = next;
    }

    public abstract void doHandler(Member member);

    public static class Builder {

        private Handler head;
        private Handler tail;

        public Builder add(Handler handler) {
            if (head == null) {
                this.head = this.tail = handler;
            }

            this.tail.next = handler;
            this.tail = handler;
            return this;
        }

        public Handler build() {
            return this.head;
        }
    }
}
